<?php
/******************************************
/* Shortcodes
******************************************/

/* ------- Testimonial --------*/
function testimonial_shortcode( $atts, $content = null ) {
   return '<div class="testimonial-shortcode"><div class="testimonial-shortcode-right">' . $content . '</div></div>';
}

add_shortcode( 'testimonial', 'testimonial_shortcode' );

/* ------- Back to Top --------*/
function back_to_top_shortcode() {
   return '<div class="back-top-top-shortcode"><a href="#" title="Back To Top" class="go-top">Top</a></div>';
}

add_shortcode( 'top', 'back_to_top_shortcode' );

/* ------- Break --------*/
function line_break_shortcode() {
   return '<br />';
}

add_shortcode( 'break', 'line_break_shortcode' );

/* ------- highlights --------*/
function highlight_shortcode( $atts, $content = null )
{
	extract( shortcode_atts(
	array(
      'color' => 'yellow',
      ),
	  $atts ) );

      return '<span class="text-highlight highlight-' . $color . '">' . $content . '</span>';

}
add_shortcode('highlight', 'highlight_shortcode');

/* ------- Buttons --------*/
function button_shortcode( $atts, $content = null )
{
	extract( shortcode_atts( array(
      'color' => 'default',
	  'url' => '',
	  'size' => 'default',
      'align' => 'default',
	  'text' => ''
      ), $atts ) );
	  if($url) {
		return '<a href="' . $url . '"><div class="button button-size-' . $size . ' button-color-' . $color . ' button-align-' . $align . '"><span>' . $text . $content . '</span></a></div>';
	  } else {
		return '<div class="button button-size-' . $size . ' button-color-' . $color . ' button-align-' . $align . '"><span>' . $text . $content . '</span></div>';
	}
}
add_shortcode('button', 'button_shortcode');


/* ------- Boxes --------*/
function box_shortcode( $atts, $content = null )
{
	extract( shortcode_atts( array(
      'color' => 'gray',
      'size' => 'normal',
      'type' => '',
	  'align' => 'default',
      ), $atts ) );

      return '<div class="complete-box-size-' . $size . ' complete-box-color-' . $color . ' complete-box-align-' . $align . ' complete-box-type-' . $type . '"><div class="complete-box-inner">' . $content . '</div></div>';

}
add_shortcode('box', 'box_shortcode');
add_filter('the_content', 'do_shortcode');
add_filter('widget_text', 'do_shortcode');


/* ------- Drop Cap Small --------*/
function dropcap($atts, $content=null, $code="") {  
	$return = '<div class="dropcap-small">';
	$return .= $content;
	$return .= '</div>';
	return $return;
}
add_shortcode('dropcap-small' , 'dropcap' );


/* ------- Drop Cap Large --------*/
function dropcap2($atts, $content=null, $code="") {  
	$return = '<div class="dropcap-big">';
	$return .= $content;
	$return .= '</div>';
	return $return;
}
add_shortcode('dropcap-big' , 'dropcap2' );


/* ------- Sticky Note --------*/
function sticky($atts, $content=null, $code="") { 
	$return = '<div class="sticky">';
	$return .= $content;
	$return .= '</div>'; 
	return $return;
}
add_shortcode('sticky' , 'sticky' );


/* ------- Sticky Note Left Aligned --------*/
function stickyleft($atts, $content=null, $code="") { 
	$return = '<div class="stickyleft">';
	$return .= $content;
	$return .= '</div>'; 
	return $return;
}
add_shortcode('stickyleft' , 'stickyleft' );


/* ------- Sticky Note Right Aligned --------*/
function stickyright($atts, $content=null, $code="") {  
	$return = '<div class="stickyright">';
	$return .= $content;
	$return .= '</div>';
	return $return;
}
add_shortcode('stickyright' , 'stickyright' );


/* ------- 1/2 --------*/
function one_half( $atts, $content = null ) {
   return '<div class="one_half">' . do_shortcode($content) . '</div>';
}
add_shortcode('one_half', 'one_half');

function one_half_last( $atts, $content = null ) {
   return '<div class="one_half last">' . do_shortcode($content) . '</div>
   <div class="clearboth"></div>';
}
add_shortcode('one_half_last', 'one_half_last');


/* ------- 1/3 --------*/
function one_third( $atts, $content = null ) {
   return '<div class="one_third">' . do_shortcode($content) . '</div>';
}
add_shortcode('one_third', 'one_third');

function one_third_last( $atts, $content = null ) {
   return '<div class="one_third last">' . do_shortcode($content) . '</div>
   <div class="clearboth"></div>';
}
add_shortcode('one_third_last', 'one_third_last');


/* ------- 1/4 --------*/
function one_fourth( $atts, $content = null ) {
   return '<div class="one_fourth">' . do_shortcode($content) . '</div>';
}
add_shortcode('one_fourth', 'one_fourth');

function one_fourth_last( $atts, $content = null ) {
   return '<div class="one_fourth last">' . do_shortcode($content) . '</div>
   <div class="clearboth"></div>';

}
add_shortcode('one_fourth_last', 'one_fourth_last');


/* ------- Bullets (checklist) --------*/
function checklist( $atts, $content = null ) {
	$content = do_shortcode( shortcode_unautop( $content ) );
if ( '</p>' == substr( $content, 0, 4 )
and '<p>' == substr( $content, strlen( $content ) - 3 ) )
	$content = substr( $content, 4, strlen( $content ) - 7 );
   return '<div class="checklist">' . do_shortcode($content) . '</div>';
}
add_shortcode('checklist', 'checklist');


/* ------- Bullets (white) --------*/
function bullets_white( $atts, $content = null ) {
	$content = do_shortcode( shortcode_unautop( $content ) );
if ( '</p>' == substr( $content, 0, 4 )
and '<p>' == substr( $content, strlen( $content ) - 3 ) )
	$content = substr( $content, 4, strlen( $content ) - 7 );
   return '<div class="bullets_white">' . do_shortcode($content) . '</div>';
}
add_shortcode('bullets_white', 'bullets_white');


/* ------- Bullets (black) --------*/
function bullets_black( $atts, $content = null ) {
	$content = do_shortcode( shortcode_unautop( $content ) );
if ( '</p>' == substr( $content, 0, 4 )
and '<p>' == substr( $content, strlen( $content ) - 3 ) )
	$content = substr( $content, 4, strlen( $content ) - 7 );
   return '<div class="bullets_black">' . do_shortcode($content) . '</div>';
}
add_shortcode('bullets_black', 'bullets_black');

/* ------- Bullets (blue) --------*/
function bullets_blue( $atts, $content = null ) {
	$content = do_shortcode( shortcode_unautop( $content ) );
if ( '</p>' == substr( $content, 0, 4 )
and '<p>' == substr( $content, strlen( $content ) - 3 ) )
	$content = substr( $content, 4, strlen( $content ) - 7 );
   return '<div class="bullets_blue">' . do_shortcode($content) . '</div>';
}
add_shortcode('bullets_blue', 'bullets_blue');


/* ------- Bullets (blue) --------*/
function bullets_red( $atts, $content = null ) {
	$content = do_shortcode( shortcode_unautop( $content ) );
if ( '</p>' == substr( $content, 0, 4 )
and '<p>' == substr( $content, strlen( $content ) - 3 ) )
	$content = substr( $content, 4, strlen( $content ) - 7 );
	$content = do_shortcode( shortcode_unautop( $content ) );
if ( '</p>' == substr( $content, 0, 4 )
and '<p>' == substr( $content, strlen( $content ) - 3 ) )
	$content = substr( $content, 4, strlen( $content ) - 7 );
   return '<div class="bullets_red">' . do_shortcode($content) . '</div>';
}
add_shortcode('bullets_red', 'bullets_red');


/* ------- Bullets (purple) --------*/
function bullets_purple( $atts, $content = null ) {
	$content = do_shortcode( shortcode_unautop( $content ) );
if ( '</p>' == substr( $content, 0, 4 )
and '<p>' == substr( $content, strlen( $content ) - 3 ) )
	$content = substr( $content, 4, strlen( $content ) - 7 );
   return '<div class="bullets_purple">' . do_shortcode($content) . '</div>';
}
add_shortcode('bullets_purple', 'bullets_purple');


/* ------- Styled Image --------*/
function image_border($atts, $content=null, $code="") {  
	$return = '<span class="image-border">';
	$return .= $content;
	$return .= '</image-border>';
	return $return;
}
add_shortcode('image_border' , 'image_border' );


/* -------- contact form -------*/
function complete_contact( $atts, $content = null)	{

	extract( shortcode_atts( array(
      'email' => get_bloginfo('admin_email')
      ), $atts ) );
	  
		$content .= '
		<script type="text/javascript"> 
			var $j = jQuery.noConflict();
			$j(window).load(function(){				
				$j("#contact-form").submit(function() {
				  // validate and process form here
					var str = $j(this).serialize();					 
					   $j.ajax({
					   type: "POST",
					   url: "' . get_bloginfo('stylesheet_directory') . '/functions/contact.php",
					   data: str,
					   success: function(msg){						
							$j("#note").ajaxComplete(function(event, request, settings)
							{ 
								if(msg == "OK") // Message Sent? Show the Thank You message and hide the form
								{
									result = "Your message has been sent. Thank you!";
									$j("#fields").fadeOut();
								}
								else
								{
									result = msg;
								}								 
								$j(this).html(result);							 
							});					 
						}					 
					 });					 
					return false;
				});			
			});
		</script>';
		$content .= '<div id="complete-contact" class="clear">';
			$content .= '<div id="fields">';
				$content .= '<h2>Send A Message</h2>';
				$content .= '<form id="contact-form" action="">';
					$content .= '<input name="to_email" type="hidden" id="to_email" value="' . $email . '"/>';
					$content .= '<p>';
						$content .= '<input name="name" type="text" id="name"/>';
						$content .= '<label class="errorfor="name">Name *</label>';
					$content .= '</p>';
					$content .= '<p>';
						$content .= '<input name="email" type="text" id="email"/>';
						$content .= '<label for="email">E-mail address *</label>';
					$content .= '</p>';
					$content .= '<p><textarea rows="" cols="" name="message"></textarea></p>';
					$content .= '<p><input type="submit" value="send" class="button" id="contact-submit" /></p>';
				$content .= '</form>';
			$content .= '</div><!--end fields-->';
			$content .= '<div id="note"></div> <!--notification area used by jQuery/Ajax -->';
		$content .= '</div>';
	return $content;
}
add_shortcode('contact', 'complete_contact');

?>